/**
 * 用于(项目/产品)各自单独自定义的js工具类
 **/
var mytools = {};

/**
 * 清空数据，按照样式清空；
 * 1）按照form表单Id清空：id参数#开头
 * 2）按照form表单class样式清空：id参数.开头
 */
mytools.cleanData=function(id){
	$(id).find(".clean").val("");
	$(id).find("IMG").each(function(){
		$(this).attr("src",strUtil.doNull($(this).attr("data-def"), ctx+"/images/def.jpg"));
		//$(this).next().text("选择主图");
		$(this).siblings("label").eq(2).text("");
		$(this).siblings("a").text("");
	});
}

/**
 * 清空校验规则提示信息，按照样式清空；
 * 1）按照form表单Id清空：id参数#开头
 * 2）按照form表单class样式清空：id参数.开头
 */
mytools.cleanValidate=function(id){
	var validate = $(id).data('bootstrapValidator').validate();
	validate.resetForm();
}
/**
 * 关闭模态窗口
 */
mytools.closeModal=function(id){
	$('#'+id).modal('hide');
}
/**
 * 封装的pjax跳转方法1
 */
mytools.pjax=function(url,container,fragment){
	var defcon = ".content-wrapper";
	var a=defcon;
	var b=defcon;
	if(container!=undefined &&container!=null && container!=''){
		a = container;
	}
	if(fragment!=undefined &&fragment!=null && fragment!=''){
		b = fragment;
	}
	//alert(url+"  "+a+"  "+b);
	 $.pjax({  
         url: url,  
         container: a,  
         fragment: b,
         cache: false,
         //maxCacheLength:0,
         timeout: 8000
       })
}

/**
 * 封装的load跳转方法 常用按钮跳转
 */
mytools.load=function(url){
	var histClick = clickMenu;
	$.ajaxSetup ({cache: false});
	$(".content-wrapper").load(url+" .content-wrapper>",function(resultData){
		 $result = $(resultData);
        $result.find("script").appendTo(".content-wrapper");//保证子页面的js内容能被引入进来
        clickMenu = histClick;
        showClickMenu();
	});
}


/**
 *
 *
 <table id="testData" class="table table-bordered">
 <thead> </thead>
 <tbody> </tbody>
 </table>
 var tableConfData={
    rows:[
        {"info_id":"pk245585899671257091","risk_cname":"策略风险1","risk_ename":"RISK000011"},
        {"info_id":"pk245585899675451393","risk_cname":"策略风险3","risk_ename":"RISK000013"}
    ]
};
 var tableOptions = {
        tableObj:$("#testData"),
        headArray:[{'key':'risk_cname'},{'key':'risk_ename'},{'key':'info_id'}],
        bodyData:{rows:tableConfData.rows},
        templateHead:'dataHead-template',
        headKeyAttr:'key'
    };
 var tableOptions2 = {
        tableObj:$("#testData"),
        headArray:['risk_cname','risk_ename','info_id'],
        bodyData:{rows:tableConfData.rows},
    };
 mytools.loadTableDynamicByData(tableOptions2);
 */
mytools.loadTableDynamicByList=function(tableOptions){
    console.log('loadTableDynamicByData.tableOptions',tableOptions);
    var tableObj=tableOptions.tableObj;
    var headArray=tableOptions.headArray;
    var bodyData=tableOptions.bodyData;
    var templateHead=strUtil.doNull(tableOptions.templateHead,'');
    var headKeyAttr = strUtil.doNull(tableOptions.headKeyAttr,'');

    if(!(headArray[0] instanceof Object)){//判断头部元素是否是对象/字符串,对象必须传headKeyAttr指定那个取那个属性
        headKeyAttr='';
        templateHead='';
        console.log('headKeyAttr->',headKeyAttr);
    }

    var head_html = "";
    if(!strUtil.isNull(templateHead)){
        console.log('table header use custom template,template id is->',templateHead);
        head_html=baidu.template(templateHead,eval({rows:headArray}))//表头模板参数非空则使用参数模板
    }else{
        //默认表头模板
        head_html = "<tr>";
        for(var k in headArray){
            if(!strUtil.isNull(headKeyAttr)){
                head_html += "<td>"+headArray[k][headKeyAttr]+"</td>";
            }else{
                head_html += "<td>"+headArray[k]+"</td>";
            }
        }
        head_html += "</tr>";
        console.log('table header use default append mode,append content is->',head_html);
    }
    tableObj.find("thead").html(head_html);

    var templateBody = "<? for ( var i = 0; i <rows.length; i++) {?>";
    templateBody+="<tr>";
    for(var j in headArray){
        var fiedAttrName = headArray[j];
        if(!strUtil.isNull(headKeyAttr)){
            fiedAttrName = headArray[j][headKeyAttr];
        }
        templateBody += "<td><?=strUtil.doNull(rows[i]."+fiedAttrName+",'')?></td>";
    }
    templateBody += "</tr><?}?>";
    var badyhtml=baidu.template(templateBody,eval(bodyData));
    // console.log(badyhtml,"1111111111111111");
    tableObj.find("tbody").html(badyhtml);


    // var tableTbody = $("#testData").find("tbody")[0];
    // var tableRowsData = mmData.rows;
    // for(var i=0;i<tableRowsData.length;i++){
    //     var row=tableTbody.insertRow(tableTbody.rows.length);
    //     for(var keys in attrDataMap){
    //         var j=0;
    //         var c1=row.insertCell(j);
    //         c1.innerHTML=strUtil.doNull(tableRowsData[i][keys],'');
    //         j++;
    //     }
    // }
}

/**
 * mytools.loadTableDynamicByInfo(tableOptions);
 var info_data = {
		"entType": "有限责任公司(自然人独资)",
		"jyfw": "一般经营项目：植物提取物（不含食品药品）、化妆品添加剂的销售、研发、技术服务；化工产品（不含易燃易爆危险品）的销售、研发、技术服务；生物技术、化工技术领域的技术服务；货物与技术的进出口经营（国家限制和禁止的货物与技术的进出口除外）。（以上经营范围除国家专控及前置许可项目）",
		"entName": "西安绿泽生物技术有限公司",
		"jyqx": "2013-03-13",
		"clrq": "2013-03-13",
		"zczb": 100.000000,
		"zhusuo": "陕西省西安市高新区高新六路六号西辛庄18排7号8302室",
		"djrq": "2013-03-13",
		"fddbr": "张乾生",
		"tyxydm": "91610131057145972X"
	};
 var configData0 = {tyxydm:'统一信用代码',entType:'企业类型',jyfw:'经营范围',entName:'企业名称'};
 var configData = [
 {paramEname:'tyxydm',paramCname:'统一信用代码'},
 {paramEname:'entType',paramCname:'企业类型'},
 {paramEname:'jyfw',paramCname:'经营范围'},
 {paramEname:'zhusuo',paramCname:'住所'},
 {paramEname:'zczb',paramCname:'注册资本'}
 ];
 var tableOptions = {
		tableObj:$("#testData"),
		bodyData:info_data,
		titleConf:configData,
		titleConfKey:'paramEname',
		titleConfText:'paramCname'
	};
 * @param tableOptions
 */
mytools.loadTableDynamicByInfo=function(tableOptions){
    console.log('loadTableDynamicByInfo.tableOptions',tableOptions);
    var tableObj=tableOptions.tableObj;
    var bodyData=tableOptions.bodyData;
    var bodyTemplateId=strUtil.doNull(tableOptions.bodyTemplateId,'');
    var titleConfObj = strUtil.doNull(tableOptions.titleConf,{});
    var titleConfKey = strUtil.doNull(tableOptions.titleConfKey,'');
    var titleConfText = strUtil.doNull(tableOptions.titleConfText,'');
    var titleClass = strUtil.doNull(tableOptions.titleClass,'active');

    var titleConfMap = {};
    if(titleConfObj instanceof Array){
        //从数组中获取配置的中英文解释
        if(strUtil.isNull(titleConfKey)||strUtil.isNull(titleConfText)){
            console.log("发生错误：titleConfKey和titleConfText参数不能为空！！");
        }
        for(var k=0;k<titleConfObj.length;k++){
            var fcobj = titleConfObj[k];
            var showKey = fcobj[titleConfKey];
            var showText = fcobj[titleConfText];
            titleConfMap[showKey]=showText;
        }
    }else{
        titleConfMap = titleConfObj;
    }
    console.log('titleConfMap',titleConfMap);
    var arrayData = [];
    for(var keys in bodyData){
        var item = {
            fiedAttrName:keys,
            fielAttrText:strUtil.doNull(titleConfMap[keys],keys),
            fiedAttrValue:strUtil.doNull(bodyData[keys],'')
        };
        arrayData.push(item);
    }
    console.log('arrayData',arrayData);
    var templateBody=bodyTemplateId;
    if(strUtil.isNull(templateBody)){
        templateBody = "<? for ( var i = 0; i <rows.length; i++) {?>";
        templateBody +="<tr>";
        templateBody += "<td class="+titleClass+" title=字段名:<?=strUtil.doNull(rows[i].fiedAttrName,'')?>><?=strUtil.doNull(rows[i].fielAttrText,'')?></td>";
        templateBody += "<td class='td-word-break'><?=strUtil.doNull(rows[i].fiedAttrValue,'')?></td>";
        templateBody += "</tr>";
        templateBody += "<?}?>";
    }
    var bodyDataNew = {rows:arrayData};
    console.log('bodyData.new',bodyDataNew);
    var bodyDataHtml =baidu.template(templateBody,eval(bodyDataNew));
    tableObj.find("tbody").html(bodyDataHtml);
}

/**
 * 根据目标数据替换原始数据同名key的值
 * @param sourData 原始数据
 * @param targetData 目标数据
 */
mytools.matchRestByParams=function(sourData,targetData){
    for(var key in sourData){
        var objdata = sourData[key];
        if(typeof(objdata) == 'string'){
            if(targetData[key]){
                sourData[key]=targetData[key];
            }
        }else{
            mytools.matchRestByParams(objdata,targetData);
        }
    }
}
/**
 * 站点以端口方式访问时，需要替换top连接地址
 * @param thisObj
 * @param findStr
 * @param newStr
 */
mytools.portRequestReplaceLink=function(thisObj) {
    if(window.location.port){
        //  console.log("请求方式：","因IP+端口方式，需top.html的a标签href地址内["+findStr+"] 替换为 ["+newStr+"]");
		var newStr = '/wcm/'+siteCode+'/';
		var findStr = '../../../';
        $("[data-repla-port-link='true']").find("a[href^='"+findStr+"']").each(function () {
            var regExpB=new RegExp(findStr,"g");
            $(this).attr("href",$(this).attr("href").replace(regExpB,newStr));
            // $(this).attr("href",$(this).attr("href").replace(/\..\/..\//g,"\/wcm\/ttwl\/"));
            // console.log($(this).text()+"-new-->",$(this).attr("href"));
        });
        $("[data-repla-port-link='true']").find("img[src^='"+findStr+"']").each(function () {
            var regExpB=new RegExp(findStr,"g");
            // console.log("old-->",$(this).attr("src"));
            $(this).attr("src",$(this).attr("src").replace(regExpB,newStr));
            // console.log("new-->",$(this).attr("src"));
        });
    }
}
/**
 判断form表单中某字段输入值是否已重复（调用后台）
 1、需要判重的文本框添加下面事件和属性
 onblur="mytools.validFieldRepeat(this)"
 data-validate-repeat-message="此登录账号已存在，请更换！"  //发现重复提示的文字
 2、修改时文本框需多配置下面这个属性。其值是editForm表单存业务主键的隐藏域name值
 data-validate-repeat-selfname="ssInsurPro.w_infoId"
 */
mytools.validFieldRepeat=function(obj){
    var thisObj = $(obj);
    var thisVal = thisObj.val();
    if(strUtil.isNull(thisVal)){
        return;
    }
    var fieldName = thisObj.attr("name");
    if(strUtil.isNull(fieldName)||fieldName.indexOf('.')<0){
        layer.msg('name属性配置不合法');
        return;
    }
    var formId = thisObj.parents("form").eq(0).attr("id");//获取当前元素所在父层级中的就近的formId
    if(strUtil.isNull(formId)<0){
        layer.msg(fieldName+'元素必须存放form表单内！');
        return;
    }
    console.log('formId->'+formId);
    var formObj =  $("#"+formId);
    var form_pageName = formObj.find("input[name='pageName']").val();
    var form_formName = formObj.find("input[name='formName']").val();
    var isEdit = false;//标记是否是修改表单
    if(form_formName=='editForm'){
        isEdit = true;
    }
    var fieldArr = fieldName.split(".");
    var objName = fieldArr[0];
    var condisStr = objName+".w_"+fieldArr[1];
    var pageName = strUtil.doNull(thisObj.attr("data-validate-repeat-page-name"),form_pageName);
    var formName = strUtil.doNull(thisObj.attr("data-validate-repeat-form-name"),'searchForm');
    var objMsg = strUtil.doNull(thisObj.attr("data-validate-repeat-message"),"此项输入的值已重复，请更换！");
    var isClean = strUtil.doNull(thisObj.attr("data-validate-repeat-clean"),'true');
    console.log('valid.req',pageName+'='+pageName+'&'+formName+'='+formName+'&'+condisStr+'='+thisVal);
    var selfInput = thisObj.attr("data-validate-repeat-selfname");
    var editRemoveId_name = '',editRemoveId_val='';
    if(isEdit){
        if(strUtil.isNull(selfInput)){
            layer.msg(formId+'下'+fieldName+'必须设置属性：data-validate-repeat-selfname');
            return;
        }
        var selfInputObj = formObj.find("input[name='"+selfInput+"']");
        if(!selfInputObj || strUtil.isNull(selfInputObj.val())){
            layer.msg(formId+"下"+fieldName+"input[name='"+selfInput+"']元素不存在或值为空！");
            return;
        }
        editRemoveId_name =selfInput.split('w_')[1];
        editRemoveId_val = selfInputObj.val();
        console.log('valid.type','edit->'+editRemoveId_name+'='+editRemoveId_val);
    }else{
        console.log('valid.type','add');
    }
    var index_load = layer.load(1, {shade: false});
    var paramLoadData = {};
    paramLoadData['pageName']=pageName;
    paramLoadData['formName']=formName;
    paramLoadData[condisStr]=thisVal;
    $.getJSON(common_list_url,paramLoadData, function(myData2){
        console.log('valid.res',myData2);
        layer.close(index_load);
        if(myData2.total>0){
            if(isEdit){
                //修改情况下，排除自己判断（自己改自己）
                if(myData2.rows[0][objName]){
                    var oldInfoIdVal = myData2.rows[0][objName][editRemoveId_name];
                    if(editRemoveId_val==oldInfoIdVal){
                        return;
                    }
                }else{
                    var oldInfoIdVal = myData2.rows[0][editRemoveId_name];
                    if(editRemoveId_val==oldInfoIdVal){
                        return;
                    }
                }
            }
            console.log('valid.msg'+objMsg);
            layer.msg(objMsg);
            if(isClean=='true'){
                thisObj.val('');
                formObj.data('bootstrapValidator').updateStatus(fieldName,'NOT_VALIDATED',null).validateField(fieldName);
            }
        }
    });
}

/**
$(function(){
    $("[data-temp-code]").each(function(){
        var thisObj = $(this);
        var objId = thisObj.attr("id");
        var code = thisObj.attr("data-temp-code");
        //console.log("加载["+siteCode+"]的["+code+"]栏目数据...");
        var tempType = thisObj.attr("data-temp-type");
        var dataTempRows = doNull(thisObj.attr("data-temp-rows"),5);
        var dataTempHeight = doNull(thisObj.attr("data-temp-height"),"200px");//默认高度
        var dataDefVal = doNull(thisObj.attr("data-temp-def"),"/images/def6.jpg");
        var dataTempCols = doNull(thisObj.attr("data-temp-cols"),"12");

        //alert(objId+"|"+code+"|"+tempType+"|"+dataTempRows);

        var tempId = objId;
        if(!isNull(tempType)){
            tempId = tempType+"-template";
        }else{
            alert(objId+"缺少data-temp-type元素");
            return;
        }
        if("banner"==tempType || "bannerTitle"==tempType){
            //tempType=banner单独处理
            tempId = tempType+"-template";
            var objMap = {};
            objMap.objId=objId;
            objMap.code=code;
            objMap.tempId=tempId;
            objMap.dataTempRows=dataTempRows;
            objMap.dataTempHeight=dataTempHeight;
            objMap.dataDefVal = dataDefVal;
            objMap.dataTempCols = dataTempCols;
            loadBannerBox(objMap);
        }else if("thisId"==tempType){
            //tempType=data
            tempId = objId+"-template";
            $.getJSON("../data/"+code+".json",function(myData){
                myData.siteCode=siteCode;
                myData.dataTempRows=dataTempRows;
                myData.dataTempHeight=dataTempHeight;
                myData.dataDefVal = dataDefVal;
                myData.dataTempCols = dataTempCols;
                var htmlContent = baidu.template(tempId,eval(myData));
                $("#"+objId).html(htmlContent);
            });
        }else{
            $.ajaxSetup ({cache: false});
            $.getJSON("../data/"+code+".json",function(myData){
                myData.siteCode=siteCode;
                myData.dataTempRows=dataTempRows;
                myData.dataTempHeight=dataTempHeight;
                myData.dataDefVal = dataDefVal;
                myData.dataTempCols = dataTempCols;
                var htmlContent = baidu.template(tempId,eval(myData));
                $("#"+objId).html(htmlContent);
            });
        }
    });

    $("[data-repla-port-link='true']").each(function () {
        mytools.portRequestReplaceLink($(this));
    });

});
**/
//json数据格式化展示，支持可收缩
mytools.showJsonViewer=function (data,id){
    $('#'+id).text('');
    // var data ={"id":1001,"type":"donut","name":"Cake","description":"https://en.wikipedia.org/wiki/Doughnut","price":2.55,"available":{"store":42,"warehouse":600},"toppings":[{"id":5001,"type":"None"},{"id":5002,"type":"Glazed"},{"id":5005,"type":"Sugar"},{"id":5003,"type":"Chocolate"},{"id":5004,"type":"Maple"}],"uuids":["826b23ce-2669-4122-981f-3e2e4429159d","e32111a0-6a87-49ab-b58f-a01bf8d28ba0","c055a894-698e-41c0-b85f-7510a7351d9d"]};
    var options = {
        collapsed: false,//是否全部收缩
        rootCollapsable: true,//根目录是否可收缩
        withQuotes: true
    };
    $('#'+id).jsonViewer(data, options);
};
//json数据格式化展示
mytools.showViewByJson=function (data,id){


    // var data ={"name":"张三","age":25,"color":"#ffa500","gender":"男","location":{"city":"北京","dist":"海淀区","other":{"user":"test","ab":10}},"family":[{"name":"孩子1","age":"10"},{"name":"孩子2","age":"20"}]};
    var code_json = document.querySelector('#'+id);
    // console.log(code_json.tagName,"code_json");
    if("TEXTAREA"==code_json.tagName){
        $('#'+id).val('');
        $('#'+id).val(JSON.stringify(data, null,4));
    }else{
        $('#'+id).text('');
        code_json.textContent = JSON.stringify(data, null,4);
    }
};
//xml格式化工具
mytools.showXmlFormat=function (id,data,prefix){
    $('#'+id).text('');
    //判断是否默认了前缀版本号和编码
    var start_prefix = (prefix==undefined||prefix=='')?'<?xml version="1.0" encoding="UTF-8"?>':prefix;
    //获取原始根目录name
    var srcRootTagName = $($.parseXML(data)).find("*").eq(0).prop("tagName").toLowerCase();
    //转换json后，在回转xml指定根节点名称
    var xmlNewStr = $.json2xml($.xml2json(data),{'rootTagName':srcRootTagName});
    //拼接开始内容
    var resXml=start_prefix+'\n'+xmlNewStr;

    $('#'+id).text(resXml);
}
//加载CMS发布的栏目数据，作为Banner images
function loadBannerBox(paramMap){
    $.getJSON("../data/"+paramMap["code"]+".json",function(myData){
        console.log(myData);
        //解析数据
        myData.siteCode=siteCode;
        myData.dataTempRows=paramMap["dataTempRows"];
        myData.dataTempHeight=paramMap["dataTempHeight"];
        myData.dataDefVal = paramMap["dataDefVal"];
        myData.dataTempCols = paramMap["dataTempCols"];
        var dataHtml = baidu.template(paramMap["tempId"],eval(myData));
        var objId = paramMap["objId"];
        $("#"+objId).html(dataHtml);
        //初始化Banner 的滚屏插件 fullSlide
        $("#"+objId).find(".fullSlide").hover(function(){
                $(this).find(".prev,.next").stop(true, true).fadeTo("show", 0.5)
            },
            function(){
                $(this).find(".prev,.next").fadeOut()
            });
        $("#"+objId).find(".fullSlide").slide({
            titCell: ".hd ul",
            mainCell: ".bd ul",
            effect: "fold",
            autoPlay: true,
            autoPage: true,
            trigger: "click",
            startFun: function(i) {
                var curLi = jQuery(".fullSlide .bd li").eq(i);
                if ( !! curLi.attr("_src")) {
                    curLi.css("background-image", curLi.attr("_src")).removeAttr("_src")
                }
            }
        });
    });
}

function isNull(str){
    if(null==str||undefined==str){
        return true;
    }
    if(""==str||"null"==str||"undefined"==str||JSON.stringify(str).trim().length==0){
        return true;
    }
    return false;
}
function doNull(str, defVal){
    if(isNull(str)){
        return defVal;
    }
    return str;
}


//计算bootstrapTable首次初始化显示的页码数
mytools.getCountShowPageSize=function (searcBoxId) {
    var first_rows = 10;
    var box_search_form_height = 0;
    if(!isNull(searcBoxId)){
        box_search_form_height = Math.ceil($(searcBoxId).outerHeight(true));
    }
    var win_height = $(window).height();
    var other_height = 320;//其他高度（底部+表头+其他微调空格）
    var table_tbody_max_height = win_height - box_search_form_height - other_height;
    var trHeight = 40;
    if(table_tbody_max_height>trHeight){
        first_rows = Math.floor(table_tbody_max_height/trHeight);
    }
    console.log("mytools.initBootstrapTable.getCountShowPageSize->","window_height="+win_height+",box_search_form_height="+box_search_form_height+",table_tbody_max_height="+table_tbody_max_height+",first_rows="+first_rows);
    return first_rows;
}
mytools.initBootstrapTable=function (config) {
    var configJson = {
        url : doNull(config.url,''),
        searcBoxId : doNull(config.searcBoxId,''),
        exportFileName : doNull(config.exportFileName,'数据导出')
    };
    console.log("mytools.initBootstrapTable.config->",configJson);
    var searchFormId = $(configJson.searcBoxId).find("form").attr("id");
    $table.bootstrapTable({
        url:configJson.url,
        // pageSize:mytools.getCountShowPageSize(configJson.searcBoxId),//【个性需求】自定义根据页面窗口高度重写计算高度方法
        sidePagination:"server",
        queryParamsType:'undefined',//采用服务端分页方式为此值
        queryParams:function (params) {//请求服务器数据参数
            //当sidePagination="server"时此值设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
            //默认是设置为limit可以获取limit, offset, search, sort, order
            console.log("mytools.bootstrapTable.params.old->",params);
            // $("#"+searchFormId).find("input[name='cateEname']").val(params.searchText);
            var param =  FormUtil.serializeJson("#"+searchFormId);
            param["page"]=params.pageNumber;
            param["rows"]=params.pageSize;
            var sortName = params.sortName;
            if(!isNull(params.sortName)){
                var sort_objname = sortName.split(".")[0];
                var sort_filed = sortName.split(".")[1];
                sort_filed=sort_filed.replace(/\B([A-Z])/g, '_$1').toLowerCase();//驼峰转下划线
                param["orderBy"]=sort_objname+'.'+sort_filed+' '+params.sortOrder;
            }
            console.log("mytools.bootstrapTable.params->",param);
            return param;
        },
        exportDataType: "all", //basic', 'all', 'selected'.
        exportOptions:{
            ignoreColumn: [0],//导出时忽略第一列
            fileName:configJson.exportFileName
        },
        exportTypes:['excel','json','txt','csv'],//导出类型
        // rowStyle: function (row, index) {
        //     var classesArr = ['success', 'info'];
        //     var strclass = "";
        //     if (index % 2 === 0) {//偶数行
        //         strclass = classesArr[0];
        //     } else {//奇数行
        //         strclass = classesArr[1];
        //     }
        //     return { classes: strclass };
        // },//隔行变色,
        onLoadSuccess: function(data){//加载成功时执行
            console.log("mytools.bootstrapTable.onLoadSuccess",data);
        },
        onLoadError: function(status){//加载失败时执行
            console.log("mytools.bootstrapTable.onLoadError",status);
        },
        onRefresh: function(param){//加载失败时执行
            console.log("mytools.bootstrapTable.onRefresh",param);
        }
    });
}
//获取序号
mytools.funPageNumber = function(value, row, index) {
    //获取每页显示的数量
    var pageSize=$table.bootstrapTable('getOptions').pageSize;
    //获取当前是第几页
    var pageNumber=$table.bootstrapTable('getOptions').pageNumber;
    //返回序号，注意index是从0开始的，所以要加上1
    return pageSize * (pageNumber - 1) + index + 1;
}
/*  获取当前日期前N天 days为天数  type无返回一个日期列子 '2020-10-10'
type=arr 返回区间日期数组['2020-10-09','2020-10-10']  */
function getBeforeDate(days,type){
    if(type == 'arr'){
        var now=new Date().getTime();
        var arrDate = [];
        for(var i=0;i<days;i++){
            var ago=now-86400000*i;//一天的毫秒数为86400000
            var agoData= new Date(ago);
            var year = agoData.getFullYear();
            var mon = agoData.getMonth() + 1;
            var day = agoData.getDate();
            mon=mon<10? '0'+mon:mon;
            day=day<10? '0'+day:day;
            var date=year+'-'+mon+'-'+day;
            arrDate.unshift(date);
        }
        return arrDate;
    }else{
        var now=new Date().getTime();
        var ago=now-86400000*days;//一天的毫秒数为86400000
        var agoData= new Date(ago);
        var year = agoData.getFullYear();
        var mon = agoData.getMonth() + 1;
        var day = agoData.getDate();
        mon=mon<10? '0'+mon:mon;
        day=day<10? '0'+day:day;
        var date=year+'-'+mon+'-'+day;
        return date;
    }
};